<?php
require_once 'config.php';
$conn=mysql_connect($host,$user,$password);

if(!conn)
{
session_start();
$_SESSION['error1']="Sorry Unable to connect!";
}
else
{
	
	if(!mysql_select_db($db))
	{
session_start();	
	$_SESSION['error1']="Sorry Unable to connect!";
	}

}
function authanti($username,$password)
{
	$queryres=mysql_query("SELECT * FROM user WHERE Login_Username='$username' AND Password='$password'");
	if($queryres)
	{
	if(mysql_num_rows($queryres)==0)
	{
	return false;
	}
	elseif(mysql_num_rows($queryres)==1)
	{
		return true;
		
	mysql_free_result($queryres);
	}
	else
	{ 
		mysql_free_result($queryres);
	
		return false;
	
	}
	}
		else
{
	$_SESSION['error1']="Incorrect username or password!";
}
}

function loggedin()
{
	if(isset($_SESSION['username']) && isset($_SESSION['password']))
	{
	
		if(authanti($_SESSION['username'],$_SESSION['password']))
		{
			return false;
		}
		else
		return true;
	}
}
$basedir="http://localhost/Schools_management_system/SMS";

?>